//
//  PlanCell.m
//  test
//
//  Created by 朱圳 on 2018/1/11.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "PlanCell.h"
#import "UILabel+HgLabel.h"
@implementation PlanCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
    }
    return self;
}
-(void)createUI{
    
    UILabel *kmLab = [[UILabel alloc]init];
    kmLab.text = @"数学";
    kmLab.numberOfLines = 0;
    kmLab.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:kmLab];
    [kmLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(40);
        make.width.mas_equalTo(40);
        make.top.equalTo(kmLab.superview.mas_top).with.offset(5);
        make.bottom.equalTo(kmLab.superview.mas_bottom).with.offset(-5);
    }];
    self.kmLab = kmLab;
    UILabel *contentLab = [[UILabel alloc]init];
    contentLab.text = @"1.昨天的错题回顾;\n2.《李永乐复习全书》逐题精讲班第5课～7课学习;\n2.《李永乐复习全书》逐题精讲班第5课～7课学习;";
    contentLab.font = [UIFont systemFontOfSize:14];
    contentLab.textAlignment = NSTextAlignmentCenter;
    contentLab.numberOfLines = 0;
    contentLab.attributedText = [contentLab getAttributedStringWithString:contentLab.text lineSpace:2];
    [self.contentView addSubview:contentLab];
    // 布局
    [contentLab mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(contentLab.superview.mas_left).with.offset(95);
        make.right.equalTo(contentLab.superview.mas_right).with.offset(-40);
        make.top.equalTo(contentLab.superview.mas_top).with.offset(5);
        make.bottom.equalTo(contentLab.superview.mas_bottom).with.offset(-5);
    }];
    self.contentLab = contentLab;
//    UILabel *zyLab = [[UILabel alloc]init];
//    zyLab.text = @"《居余马线性代数》\n P10~20";
//    zyLab.font = [UIFont systemFontOfSize:12];
//    zyLab.numberOfLines = 0;
//    zyLab.textAlignment = NSTextAlignmentCenter;
//    [self.contentView addSubview:zyLab];
//    [zyLab mas_updateConstraints:^(MASConstraintMaker *make) {
//        [make.left.mas_equalTo(contentLab.mas_right) setOffset:10];
//        make.right.equalTo(zyLab.superview.mas_right).with.offset(-30);
//        make.centerY.mas_equalTo(self);
//    }];
//    self.zyLab = zyLab;
    /**********************分割线******************************/
    //顶部
    UIView *xview1 = [[UIView alloc]init];
    xview1.backgroundColor = [UIColor darkGrayColor];
    [self.contentView addSubview:xview1];
    [xview1 mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(kmLab.mas_left) setOffset:-10];
        make.top.mas_equalTo(self);
        make.height.mas_equalTo(0.5);
        [make.right.mas_equalTo(contentLab.mas_right) setOffset:10];
    }];
    //底部
    UIView *xview2 = [[UIView alloc]init];
    xview2.backgroundColor = [UIColor darkGrayColor];
    [self.contentView addSubview:xview2];
    [xview2 mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(kmLab.mas_left) setOffset:-10];
        make.bottom.mas_equalTo(self);
        make.height.mas_equalTo(0.5);
        [make.right.mas_equalTo(contentLab.mas_right) setOffset:10];
    }];
    //竖线
    UIView *xview3 = [[UIView alloc]init];
    xview3.backgroundColor = [UIColor darkGrayColor];
    [self.contentView addSubview:xview3];
    [xview3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xview2.mas_left);
        make.bottom.mas_equalTo(self);
        make.top.mas_equalTo(self);
        make.width.mas_equalTo(1);
    }];
    
    UIView *xview4 = [[UIView alloc]init];
    xview4.backgroundColor = [UIColor darkGrayColor];
    [self.contentView addSubview:xview4];
    [xview4 mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(kmLab.mas_right) setOffset:8];
        make.bottom.mas_equalTo(self);
        make.top.mas_equalTo(self);
        make.width.mas_equalTo(1);
    }];
    
    UIView *xview5 = [[UIView alloc]init];
    xview5.backgroundColor = [UIColor darkGrayColor];
    [self.contentView addSubview:xview5];
    [xview5 mas_makeConstraints:^(MASConstraintMaker *make) {
       // [make.left.mas_equalTo(contentLab.mas_right) setOffset:8];
        make.right.mas_equalTo(xview2.mas_right);
        make.bottom.mas_equalTo(self);
        make.top.mas_equalTo(self);
        make.width.mas_equalTo(1);
    }];
    
//    UIView *xview6 = [[UIView alloc]init];
//    xview6.backgroundColor = [UIColor darkGrayColor];
//    [self.contentView addSubview:xview6];
//    [xview6 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(xview2.mas_right);
//        make.bottom.mas_equalTo(self);
//        make.top.mas_equalTo(self);
//        make.width.mas_equalTo(1);
//    }];
}

-(void)setModel:(PlanModel *)model{
    _model = model;
    self.kmLab.text = _model.coursename;
  //  self.contentLab.text = _model.coursename;
//    self.contentLab.text = _model.content;
//    self.zyLab.text = _model.content;
}
@end

